package com.hqyj.controller;


import com.hqyj.entity.SearchBean;
import com.hqyj.pojo.TbHouse;
import com.hqyj.service.TbHouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;

/**
 * <p>
 * 房屋表 前端控制器
 * </p>
 *
 * @author gp
 * @since 2021-09-26
 */
@RestController
@RequestMapping("/tb-house")
public class TbHouseController {

    @Autowired
    TbHouseService tbHouseService;

    /**
     * 查询房产
     * 127.0.0.1:8080/tb-house/list ---- get
     */
    @GetMapping("/list")
    public HashMap<String, Object> list(TbHouse tbHouse){
        return tbHouseService.list(tbHouse);
    }

    @GetMapping("/listPage")
    public HashMap<String, Object> listPage(SearchBean searchBean){
        return tbHouseService.listPage(searchBean);
    }


    /**
    * @Description:
     * 新增业主
     * 127.0.0.1:8080/tb-house/add ---- post
    * @Date:2021/9/30 11:04
    */
    @PostMapping(value = "/add", consumes = "application/json")
    public HashMap<String,Object> insert(@RequestBody TbHouse tbHouse){
        return tbHouseService.insert(tbHouse);
    }
    /**
    * @Description:
     * 127.0.0.1:8080/tb-house/update ---- put
    * @Date:2021/9/30 13:23
    */
    @PutMapping(value = "/update", consumes = "application/json")
    public HashMap<String ,Object> update(@RequestBody TbHouse tbHouse){
        return tbHouseService.update(tbHouse);
    }

    /**
     * 127.0.0.1:8080/tb-house/del/{id} ---- delete
     */
    @DeleteMapping("/del/{id}")
    public HashMap<String, Object> del(@PathVariable Integer id){
        return tbHouseService.del(id);
    }
}

